<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加员工</title>
    <style>
        /* 替换成第二个HTML代码中的样式部分 */
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 0;
            display: flex;
            min-height: 100vh;
        }
        #sidebar {
            width: 200px;
            background-color: #007BA7;
            color: white;
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .nav-item {
            width: 100%;
            background-color: #1fbaf1;
            color: white;
            padding: 10px 20px;
            margin-bottom: 10px;
            text-align: center;
            cursor: pointer;
        }
        .nav-item a {
            display: block;
            width: 100%;
            height: 100%;
            text-decoration: none;
        }
        a {
            text-decoration: none;
            color: #007BA7;
        }
        a:hover {
            text-decoration: underline;
        }
        .nav-item:hover, .nav-item:focus {
            background-color: #ffffff;
        }
        .nav-item a:active, .nav-item a:hover, .nav-item a:focus {
            text-decoration: none;
        }
        #content {
            flex: 1;
            padding: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        form {
            width: 300px;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        .form-row {
            display: flex;
            align-items: center;
            margin: 5px 0;
        }
        label {
            margin-right: 5px;
            font-weight: bold;
            width: 75px;
        }
        input[type="text"] {
            padding: 10px;
            width: 100%;
            box-sizing: border-box;
            border: 1px solid #ccc;
            border-radius: 5px;
            outline: none;
        }
        input[type="submit"] {
            background-color: #007BA7;
            color: white;
            border: none;
            cursor: pointer;
            border-radius: 5px;
            padding: 10px 20px;
            margin-top: 10px;
            transition: background-color 0.3s;
        }
        input[type="submit"]:hover {
            background-color: #005d83;
        }
    </style>
</head>
<body>
<!-- 添加导航栏 -->
<div id="sidebar">
    <div class="logo" style="margin-bottom: 5px">
        <img src="https://img0.baidu.com/it/u=2518312278,2725304941&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=502"  width="100" height="100">
    </div>
    <div class="nav-item"><a href="/list">员工列表</a></div>
    <div class="nav-item"><a href="#">添加员工</a></div>
</div>
<!-- 结束导航栏部分 -->

<div id="content">
    <form action="save" method="post" onsubmit="return validateForm()">

        <div class="form-row">
            <label>名字</label>
            <input type="text" name="name" id="name" />
        </div>
        <div class="form-row">
            <label>年龄</label>
            <input type="text" name="age" id="age" />
        </div>
        <div class="form-row">
            <label>手机号</label>
            <input type="text" name="phone" id="phone" />
        </div>
        <div class="form-row">
            <label>邮箱</label>
            <input type="text" name="email" id="email" />
        </div>
        <div class="form-row">
            <label>地址</label>
            <input type="text" name="address" id="address" />
        </div>
        <div class="form-row">
            <label>薪水/月</label>
            <input type="text" name="salary" id="salary" />
        </div>
        <div class="form-row">
            <label for="date">入职日期</label>
            <input type="date" id="date" name="date" />
        </div>
        <input type="submit" value="添加">
    </form>
    <div class="button-container">
        <a href="/list">返回</a> <!-- 返回按钮 -->
    </div>
</div>
<script>
    function validateForm() {
        var name = document.getElementById("name").value; // 获取名字输入框的值
        var age = document.getElementById("age").value; // 获取年龄输入框的值
        var phone = document.getElementById("phone").value; // 获取手机号输入框的值
        var email = document.getElementById("email").value; // 获取邮箱输入框的值
        var address = document.getElementById("address").value; // 获取地址输入框的值
        var salary = document.getElementById("salary").value; // 获取薪水输入框的值
        var date = document.getElementById("date").value; // 获取入职日期输入框的值
        // 判断所有输入框是否为空
        if (name == "" || age == "" || phone == "" || email == "" || address == "" || salary == "" || date == "") {
            alert("不得有选项未填");
            return false; // 阻止表单提交
        }
    }
</script>
</body>
</html>
